function s() {
	//获取div1
	var div1 = document.querySelectorAll('.div1 .div1-right');
	//console.log(div1);
	//获取总价
	var allCount = document.querySelector('#allCount span');
	//console.log(allCount);
	//先让总价等于0
	var allCountNum = 0;

	for(var i = 0; i < div1.length; i++) {
		//单价
		var price = div1[i].children[0].children[0].children[0].innerHTML;
		//console.log(price);
		//数量
		var num = div1[i].children[0].children[1].children[0].value;
		//console.log(num);
		//小计
		var count = div1[i].children[0].children[2].children[0].innerHTML = (price * num).toFixed(2);
		//count = price * num;
		//console.log(count);    //allCountNum+=count 等同于 allCountNum=allCountNum+1
		allCountNum += Number(count);
	}
	//赋值总价
	allCount.innerHTML = allCountNum.toFixed(2);
	//console.log(allCount.innerHTML);
}
s();

//修改
//获取div中所有的input的数量
var ipt = document.querySelectorAll(".div1-right .quantity input");
//console.log(ipt);
for(var j = 0; j < ipt.length; j++) {
	//change 元素的值发生改变
	ipt[j].addEventListener('change', s);
}

//删除
var del = document.querySelectorAll(".delete");
for(var k = 0; k < del.length; k++){
	del[k].addEventListener('click',function(){
		//console.log(this.parentNode.parentNode.parentNode);
		var div2 = document.querySelector(".main-bottom");
		//console.log(div2);
		//根据父级删除子级
		div2.removeChild(this.parentNode.parentNode.parentNode);
		//删除后执行一遍函数
		s();
	})
}